package com.lagou.article.service.impl;

import com.lagou.article.entity.Article;
import com.lagou.article.mapper.ArticleMapper;
import com.lagou.article.repository.ArticleRepository;
import com.lagou.article.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: article
 * @author: GYL
 * @create: 2020-09-29 14:55
 * @description:
 */
@Service
public class ArticleServiceImpl implements ArticleService {
    @Resource
    ArticleMapper articleMapper;
    @Autowired
    ArticleRepository articleRepository;

    @Override
    public Page list(Integer currentPage,Integer pageSize) {
        Pageable pageable = PageRequest.of(currentPage,pageSize);
        Example<Article> example = Example.of(new Article());
        Page<Article> all = articleRepository.findAll(example, pageable);
        return all;
    }
}